package bme.andraskindler.treenventory.model;

import org.opencv.core.CvType;
import org.opencv.core.Mat;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;

@Table(name = "cameradatabase")
public class CameraData extends Model {

	@Column(name = "cam00")
	private double camera00;
	@Column(name = "cam01")
	private double camera01;
	@Column(name = "cam02")
	private double camera02;
	@Column(name = "cam10")
	private double camera10;
	@Column(name = "cam11")
	private double camera11;
	@Column(name = "cam12")
	private double camera12;
	@Column(name = "cam20")
	private double camera20;
	@Column(name = "cam21")
	private double camera21;
	@Column(name = "cam22")
	private double camera22;

	@Column(name = "dist0")
	private double dist0;
	@Column(name = "dist1")
	private double dist1;
	@Column(name = "dist2")
	private double dist2;
	@Column(name = "dist3")
	private double dist3;
	@Column(name = "dist4")
	private double dist4;

	public CameraData() {
	}

	public void setCamera(Mat cam) {
		camera00 = cam.get(0, 0)[0];
		camera01 = cam.get(0, 1)[0];
		camera02 = cam.get(0, 2)[0];
		camera10 = cam.get(1, 0)[0];
		camera11 = cam.get(1, 1)[0];
		camera12 = cam.get(1, 2)[0];
		camera20 = cam.get(2, 0)[0];
		camera21 = cam.get(2, 1)[0];
		camera22 = cam.get(2, 2)[0];
	}

	public void setDist(Mat dist) {
		dist0 = dist.get(0, 0)[0];
		dist1 = dist.get(0, 1)[0];
		dist2 = dist.get(0, 2)[0];
		dist3 = dist.get(0, 3)[0];
		dist4 = dist.get(0, 4)[0];
	}

	public Mat getCamera() {
		Mat mat = new Mat(3, 3, CvType.CV_64F);

		mat.put(0, 0, camera00);
		mat.put(0, 1, camera01);
		mat.put(0, 2, camera02);
		mat.put(1, 0, camera10);
		mat.put(1, 1, camera11);
		mat.put(1, 2, camera12);
		mat.put(2, 0, camera20);
		mat.put(2, 1, camera21);
		mat.put(2, 2, camera22);

		return mat;
	}

	public Mat getDistCoeffs() {
		Mat mat = new Mat(5, 1, CvType.CV_64F);

		mat.put(0, 0, dist0);
		mat.put(0, 1, dist1);
		mat.put(0, 2, dist2);
		mat.put(0, 3, dist3);
		mat.put(0, 4, dist4);

		return mat;
	}

	public double getCamera00() {
		return camera00;
	}

	public void setCamera00(double camera00) {
		this.camera00 = camera00;
	}

	public double getCamera01() {
		return camera01;
	}

	public void setCamera01(double camera01) {
		this.camera01 = camera01;
	}

	public double getCamera02() {
		return camera02;
	}

	public void setCamera02(double camera02) {
		this.camera02 = camera02;
	}

	public double getCamera10() {
		return camera10;
	}

	public void setCamera10(double camera10) {
		this.camera10 = camera10;
	}

	public double getCamera11() {
		return camera11;
	}

	public void setCamera11(double camera11) {
		this.camera11 = camera11;
	}

	public double getCamera12() {
		return camera12;
	}

	public void setCamera12(double camera12) {
		this.camera12 = camera12;
	}

	public double getCamera20() {
		return camera20;
	}

	public void setCamera20(double camera20) {
		this.camera20 = camera20;
	}

	public double getCamera21() {
		return camera21;
	}

	public void setCamera21(double camera21) {
		this.camera21 = camera21;
	}

	public double getCamera22() {
		return camera22;
	}

	public void setCamera22(double camera22) {
		this.camera22 = camera22;
	}

	public double getDist0() {
		return dist0;
	}

	public void setDist0(double dist0) {
		this.dist0 = dist0;
	}

	public double getDist1() {
		return dist1;
	}

	public void setDist1(double dist1) {
		this.dist1 = dist1;
	}

	public double getDist2() {
		return dist2;
	}

	public void setDist2(double dist2) {
		this.dist2 = dist2;
	}

	public double getDist3() {
		return dist3;
	}

	public void setDist3(double dist3) {
		this.dist3 = dist3;
	}

	public double getDist4() {
		return dist4;
	}

	public void setDist4(double dist4) {
		this.dist4 = dist4;
	}

}
